home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1227 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  63 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: news.nic.surfnet.nl!hhinsi!news
  3. From: robv@si.hhs.nl (Veer)
  4. Subject: Re: TMapping again!
  5. Message-ID: <DLA1p3.A2n@si.hhs.nl>
  6. Sender: news@si.hhs.nl
  7. Reply-To: robv@si.hhs.nl
  8. Organization: Sector Informatica, Haagse HogeSchool, the NetherLands
  9. References: <mq2Xx*aB0@mkmk.in-chemnitz.de>
  10. Date: Tue, 16 Jan 1996 14:03:02 GMT
  11.  
  12. In article aB0@mkmk.in-chemnitz.de, floh@mkmk.in-chemnitz.de (Andre Weissflog) writes:
  13. > In article <38232018@kone.fipnet.fi>, "Jyrki Saarinen" writes:
  14. >  
  15. > Instead of 2 divs, one can also use 1 div and 2 muls:
  16. >     z' = 1 / one_div_z
  17. >     u  = u_div_z * z'
  18. >     v  = v_div_z * z'
  19.  
  20. This can even be done faster using a precalc table.
  21. Remember: a*b = log(a+b).
  22.  
  23. So you can precalc a log-table (which might get big) but you could eliminate ALL
  24. divisions and multiplications this way.
  25.  
  26. ++Pseudocode mode ON
  27.  
  28. /* create a table of longwords */
  29. for(t=0x0000;t<0xFFFF;t++)
  30. {
  31.      /* I didn't account for the fixed-point calculcations */
  32.      table[t] = log(1/t);
  33. }
  34.  
  35. ---
  36. /* now, when you need to convert 3D to 2D, do this */
  37.  
  38. u = table[u_div_z + one_div_z];
  39. v = table[v_div_z + one_div_z];
  40.  
  41. ++Pseudocode mode OFF
  42.  
  43. Ofcourse, the size of the table can be minimize by examining the results of the log
  44. table and the required precision. If the resulting values need not to be fixed-point
  45. values between 0 and 512 the size of the table could be modified accordingly.
  46.  
  47. Though I have never tested this principle, I think a major speedup in calculations can
  48. be achieved.
  49.  
  50. CYa,
  51.  
  52.     Rob.
  53.  
  54. ---
  55. Think about this for a while:
  56.  
  57. Only fools can develop fool-proof applications.
  58.  
  59.  
  60.  
  61.